import { Component } from "react";
import PubSub from "pubsub-js";
import eventBus from "../utils/eventBus";

export default class World extends Component {
  fn1 = () => {
    // 触发消息
    eventBus.emit("changeCount", "张三");
  };

  fn2 = () => {
    PubSub.publish("MSG", "张三");
  };

  render() {
    return (
      <div>
        <h2>World</h2>
        <button onClick={this.fn1}>修改 Hello 中 count</button>
        <button onClick={this.fn2}>发布</button>
      </div>
    );
  }
}
